package com.bootdo.cash.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bootdo.cash.dao.CashDao;
import com.bootdo.cash.domain.CashDO;
import com.bootdo.cash.service.ChargeService;
import com.bootdo.common.utils.DateUtils;
import com.bootdo.common.utils.StringUtils;

/**
 * @Desc
 * @date 2019/12/24
 *
 */
@Service
public class ChargeServiceImpl implements ChargeService {

    @Autowired
    private CashDao cashMapper;

    @Override
    public CashDO get(Long userId){
        return cashMapper.get(userId);
    }

    /**
     * 获取提现列表
     * @param map
     * @return
     */
    @Override
    public List<CashDO> list(Map<String, Object> map){
        //格式话日期
        String startDate = (String) map.get("startTime");
        String endDate = (String) map.get("endTime");
        if (StringUtils.isNotBlank(startDate)){
            startDate = DateUtils.getDateOfFormatByYMD(startDate, DateUtils.DATE_PATTERN_YMD,DateUtils.DATE_B_TIME_PATTERN);
            endDate = DateUtils.getDateOfFormatByYMD(endDate, DateUtils.DATE_PATTERN_YMD,DateUtils.DATE_E_TIME_PATTERN);
            map.put("startTime", startDate);
            map.put("endTime", endDate);
        }
        return cashMapper.list(map);
    }

    /**
     * 获取提现列表总条数
     * @param map
     * @return
     */
    @Override
    public int count(Map<String, Object> map){
        return cashMapper.count(map);
    }

}
